package algotithm.weekendrace.春季赛.test1;

import java.util.*;

/**
 * @author zhouyanxiang
 * @Date 2021-04-2021/4/5-15:05
 */
public class Solution {

    public static void main(String[] args) {
        Solution solution = new Solution();
        int[] nums = new int[(int) 1e5];
        Arrays.fill(nums,1);
        int target = 20;
//        int[] nums = {2,2,1,9};
//        int target = 10;
//        int[] nums = {2,5,3,5};
//        int target = 6;
        int i = solution.purchasePlans(nums, target);
        System.out.println(i);
    }

    public int purchasePlans(int[] nums, int target) {
        Arrays.sort(nums);
        int j = nums.length - 1;
        long res = 0;
        int mod = (int) (1e9 + 7);
        for (int i = 0; i < j; i++) {
            while (j > i && nums[i] + nums[j] > target) {
                j--;
            }
            res = (res + j - i) % mod;
        }
        return (int) res % mod;
    }
}




